<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<!DOCTYPE html>
<html lang="en">
<head>
<%
	String bathPath = request.getContextPath();
	pageContext.setAttribute("bathPath", bathPath);
%>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>控制器页面</title>
<link rel="stylesheet" href="${bathPath}/frame/layui/css/layui.css">
<link rel="stylesheet" href="${bathPath}/frame/static/css/style.css">
<link rel="icon" href="${bathPath}/frame/static/image/code.png">
<link type="text/css" rel="stylesheet" href="${bathPath}/css/page.css"/>
<script type="text/javascript" src="${bathPath}/js/jquery-1.9.1.min.js" ></script>
<script type="text/javascript" src="${bathPath}/js/ajaxSessionOut.js" ></script>
<!-- layer -->
<link type="text/css" rel="stylesheet" href="${bathPath}/js/layer/skin/layer.css"/>
<script type="text/javascript" src="${bathPath}/js/layer/layer.js" ></script>
<!-- validation -->
<script type="text/javascript" src="${bathPath }/js/jquery-validation/jquery.validate.js"></script>

<script src="${bathPath }/js/quickui/libs/js/form/validationRule.js" type="text/javascript"></script>
<script src="${bathPath }/js/quickui/libs/js/form/validation.js" type="text/javascript"></script>
<script src="${bathPath}/frame/layui/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script type="text/javascript">

function search(){
	var param=$("form").serialize();
	layer.confirm("保存成功", {btn: ['确定'], title: "提示",skin:"my-skin"}, function(){

		$.ajax({
			 type:"POST",
			 async:false,
			 dataType:JSON,
			 data:param,
		     url:"${bathPath}/aDKController/addController.action",
		     success:function(data){
		    	 if(data!="SUCCESS"){
						layer.msg(data);
						
					}
		     }
		 });
		//layer.msg("保存成功！");
		layer.close(layer.index);
		parent.location.reload();
	}); 
}
//页面加载
$(function(){
	  $("#qiyong").val(0);

	  $("#starttime1").attr('disabled','disabled');
	  $("#endtime1").attr('disabled','disabled');

	  $("#starttime2").attr('disabled','disabled');
	  $("#endtime2").attr('disabled','disabled');
	  
	  $("#starttime3").attr('disabled','disabled');
	  $("#endtime3").attr('disabled','disabled');
	  
	  $("#starttime4").attr('disabled','disabled');
	  $("#endtime4").attr('disabled','disabled');
	  
	  $("#starttime5").attr('disabled','disabled');
	  $("#endtime5").attr('disabled','disabled');
	  
	  $("#starttime6").attr('disabled','disabled');
	  $("#endtime6").attr('disabled','disabled');
	  
	  $("#starttime7").attr('disabled','disabled');
	  $("#endtime7").attr('disabled','disabled');
});

layui.use('form', function(){
	  var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
	  form.render();
  
      
      form.on('checkbox(test)',function(data){if(data.elem.checked==true){$("#aPBEnable").val(1);}else{$("#aPBEnable").val(0);}});
	  form.on('checkbox(test2)',function(data){if(data.elem.checked==true){$("#boxLock").val(1);}else{$("#boxLock").val(0);}});
	  form.on('checkbox(test31)',function(data){if(data.elem.checked==true){$("#interlockDoor1").val(1);}else{$("#interlockDoor1").val(0);}});
	  form.on('checkbox(test32)',function(data){if(data.elem.checked==true){$("#interlockDoor2").val(1);}else{$("#interlockDoor2").val(0);}});
	  form.on('checkbox(test33)',function(data){if(data.elem.checked==true){$("#interlockDoor3").val(1);}else{$("#interlockDoor3").val(0);}});
	  form.on('checkbox(test34)',function(data){if(data.elem.checked==true){$("#interlockDoor4").val(1);}else{$("#interlockDoor4").val(0);}});
	  form.on('checkbox(test41)',function(data){if(data.elem.checked==true){$("#sensorEnable1").val(1);}else{$("#sensorEnable1").val(0);}});
	  form.on('checkbox(test42)',function(data){if(data.elem.checked==true){$("#sensorEnable2").val(1);}else{$("#sensorEnable2").val(0);}});
	  form.on('checkbox(test43)',function(data){if(data.elem.checked==true){$("#sensorEnable3").val(1);}else{$("#sensorEnable3").val(0);}});
	  form.on('checkbox(test44)',function(data){if(data.elem.checked==true){$("#sensorEnable4").val(1);}else{$("#sensorEnable4").val(0);}});
	  form.on('checkbox(test51)',function(data){if(data.elem.checked==true){$("#doubleAction1").val(1);}else{$("#doubleAction1").val(0);}});
	  form.on('checkbox(test52)',function(data){if(data.elem.checked==true){$("#doubleAction2").val(1);}else{$("#doubleAction2").val(0);}});
      
 form.on('checkbox(test1)',function(data){
    	// alert(222);
    	 if(data.elem.checked==true){
    		$("#qiyong").val(1);
  		  $('#starttime1').attr("disabled",false);
            $("#endtime1").attr('disabled',false);
  		  
  		  $("#starttime2").attr('disabled',false);
  		  $("#endtime2").attr('disabled',false);
  		  
  		  $("#starttime3").attr('disabled',false);
  		  $("#endtime3").attr('disabled',false);
  		  
  		  $("#starttime4").attr('disabled',false);
  		  $("#endtime4").attr('disabled',false);
  		  
  		  $("#starttime5").attr('disabled',false);
  		  $("#endtime5").attr('disabled',false);
  		  
  		  $("#starttime6").attr('disabled',false);
  		  $("#endtime6").attr('disabled',false);
  		  
  		  $("#starttime7").attr('disabled',false);
  		  $("#endtime7").attr('disabled',false);
    	 } else{
    		 
   		  $("#qiyong").val(0);
		  
		  $("#starttime1").attr('disabled','disabled');
		  $("#endtime1").attr('disabled','disabled');
		  
		  $("#starttime2").attr('disabled','disabled');
		  $("#endtime2").attr('disabled','disabled');
		  
		  $("#starttime3").attr('disabled','disabled');
		  $("#endtime3").attr('disabled','disabled');
		  
		  $("#starttime4").attr('disabled','disabled');
		  $("#endtime4").attr('disabled','disabled');
		  
		  $("#starttime5").attr('disabled','disabled');
		  $("#endtime5").attr('disabled','disabled');
		  
		  $("#starttime6").attr('disabled','disabled');
		  $("#endtime6").attr('disabled','disabled');
		  
		  $("#starttime7").attr('disabled','disabled');
		  $("#endtime7").attr('disabled','disabled');
		   
    		 
    	 }
      });  
       
      
	  //……
	  
	  //但是，如果你的HTML是动态生成的，自动渲染就会失效
	  //因此你需要在相应的地方，执行下述方法来手动渲染，跟这类似的还有 element.init();

});


</script>
<script>
layui.use('element', function(){
  var $ = layui.jquery
  ,element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块
  
  //触发事件
  var active = {
    tabAdd: function(){
      //新增一个Tab项
      element.tabAdd('demo', {
        title: '新选项'+ (Math.random()*1000|0) //用于演示
        ,content: '内容'+ (Math.random()*1000|0)
        ,id: new Date().getTime() //实际使用一般是规定好的id，这里以时间戳模拟下
      })
    }
    ,tabDelete: function(othis){
      //删除指定Tab项
      element.tabDelete('demo', '44'); //删除：“商品管理”
      
      
      othis.addClass('layui-btn-disabled');
    }
    ,tabChange: function(){
      //切换到指定Tab项
      element.tabChange('demo', '22'); //切换到：用户管理
    }
  };
  
  $('.site-demo-active').on('click', function(){
    var othis = $(this), type = othis.data('type');
    active[type] ? active[type].call(this, othis) : '';
  });
  
  //Hash地址的定位
  var layid = location.hash.replace(/^#test=/, '');
  element.tabChange('test', layid);
  
  element.on('tab(test)', function(elem){
    location.hash = 'test='+ $(this).attr('lay-id');
  });
  
});
function cha(){
	alert($("#ctrlAddr").val());
	top.layer.open({
		  title:'增加时间段',
		  type: 2,
		  area:['950px', '535px'],
		  offset: ['50px','300px'],
		  content: '${bathPath}/aDKController/findId1.action?ctrlAddr='+$("#ctrlAddr").val()
		}); 
}
</script>

<style type="text/css">
	.my-skin .layui-layer-btn a {
	background-color:#009688;
}
</style>
</head>
<body>
<form class="layui-form layui-form-pane"  id="myform" method="post" action="" showOnMouseOver="false"> 
<input type="hidden" id="autoID" name="autoID" value="${kongzhi.autoID}" >
<input type="hidden" id="ctrlAddr" name="ctrlAddr" value="${kongzhi.ctrlAddr}" >
<div class="layui-tab layui-tab-card">
  <ul class="layui-tab-title">
    <li class="layui-this">基本设置</li>
    <li>高级设置</li>
    <li>非整日有效时间设置</li>
  </ul>
  <div class="layui-tab-content" style="height:350px;">
    <!--基本设置  -->
    <div class="layui-tab-item layui-show">
      <table class="param_table" style="border-collapse:separate; border-spacing:0px 10px; width:325px; margin-left:7px;">
	      <tr>
	         <td style="color:#009688;text-indent:15px;width:120px;">IP地址</td>
	         <td><input type="text" style="height:35px;" id="iP" name="iP" value="${kongzhi.iP}" lay-verify="required" autocomplete="off" class="layui-input"></td>
	      </tr>
	      <tr>
	        <td style="color:#009688;text-indent:15px;">端口号</td>
            <td><input type="text" style="height:35px;" id="port"  name="port" value="${kongzhi.port}" lay-verify="required" autocomplete="off" class="layui-input"></td>
	      </tr>
	      <tr>
	        <td style="color:#009688;text-indent:15px;">密码</td>
            <td><input type="password" style="height:35px;" id="password"  name="password" value="${kongzhi.password}" lay-verify="required" autocomplete="off" class="layui-input"></td>
	      </tr>
      </table>
    </div>
    <!--高级设置  -->
    <div class="layui-tab-item">
	     <table class="param_table" style="border-collapse:separate; border-spacing:0px 10px; width:325px; margin-left:7px;">
	      <tr>
	         <td style="color:#009688;">防潜返设置</td>
	         <td style="height:35px;" ><input type="checkbox"  id="aPBEnable"  name="aPBEnable"  lay-skin="primary" title="启用" lay-filter="test" value="${kongzhi.aPBEnable}" <c:if test="${kongzhi.aPBEnable==1 }">checked="checked"</c:if> ></td>
	         <td colspan="3"></td>
	      </tr>
	      <tr>
	        <td style="color:#009688;">防撬设置</td>
 			<td style="height:35px;"><input type="checkbox"  id="boxLock" name="boxLock" lay-skin="primary" title="启用" lay-filter="test2" value="${kongzhi.boxLock}" <c:if test="${kongzhi.boxLock==1 }">checked="checked"</c:if> ></td>
 			<td colspan="3"></td>
	      <tr>
	        <td style="color:#009688;">互锁使能</td>
            <td style="height:35px;" ><input type="checkbox" id="interlockDoor1" name="interlockDoor1" lay-skin="primary" title="1#" lay-filter="test31" value="${kongzhi.interlockDoor1 }" <c:if test="${kongzhi.interlockDoor1==1 }">checked="checked"</c:if>></td>
            <td style="height:35px;" ><input type="checkbox" id="interlockDoor2" name="interlockDoor2" lay-skin="primary" title="2#" lay-filter="test32" value="${kongzhi.interlockDoor2 }" <c:if test="${kongzhi.interlockDoor2==1 }">checked="checked"</c:if>></td>
            <td style="height:35px;" ><input type="checkbox" id="interlockDoor3" name="interlockDoor3" lay-skin="primary" title="3#" lay-filter="test33" value="${kongzhi.interlockDoor3 }" <c:if test="${kongzhi.interlockDoor3==1 }">checked="checked"</c:if>></td>
            <td style="height:35px;" ><input type="checkbox" id="interlockDoor4" name="interlockDoor4" lay-skin="primary" title="4#" lay-filter="test34" value="${kongzhi.interlockDoor4 }" <c:if test="${kongzhi.interlockDoor4==1 }">checked="checked"</c:if>></td>
	      </tr>
	      <tr>
	        <td style="color:#009688;">门磁检测</td>
            <td style="height:35px;" ><input type="checkbox" id="sensorEnable1" name="sensorEnable1" lay-skin="primary" title="1#" lay-filter="test41" value="${kongzhi.sensorEnable1}" <c:if test="${kongzhi.sensorEnable1==1 }">checked="checked"</c:if>></td>
            <td style="height:35px;" ><input type="checkbox" id="sensorEnable2" name="sensorEnable2" lay-skin="primary" title="2#" lay-filter="test42" value="${kongzhi.sensorEnable2}" <c:if test="${kongzhi.sensorEnable2==1 }">checked="checked"</c:if>></td>
            <td style="height:35px;" ><input type="checkbox" id="sensorEnable3" name="sensorEnable3" lay-skin="primary" title="3#" lay-filter="test43" value="${kongzhi.sensorEnable3}" <c:if test="${kongzhi.sensorEnable3==1 }">checked="checked"</c:if>></td>
            <td style="height:35px;" ><input type="checkbox" id="sensorEnable4" name="sensorEnable4" lay-skin="primary" title="4#" lay-filter="test44" value="${kongzhi.sensorEnable4}" <c:if test="${kongzhi.sensorEnable4==1 }">checked="checked"</c:if>></td>
	      </tr>
	      <tr>
	        <td style="color:#009688;">双向门</td>
	        <td colspan="2" style="height:35px;" ><input type="checkbox" id="doubleAction1" name="doubleAction1" lay-skin="primary" title="1#和2#" lay-filter="test51" value="${kongzhi.doubleAction1}" <c:if test="${kongzhi.doubleAction1==1 }">checked="checked"</c:if>></td>
			<td colspan="2" style="height:35px;" ><input type="checkbox" id="doubleAction2" name="doubleAction2" lay-skin="primary" title="3#和4#" lay-filter="test52" value="${kongzhi.doubleAction2}" <c:if test="${kongzhi.doubleAction2==1 }">checked="checked"</c:if>></td>
	      </tr>
      </table>
     </div>
    <!--非整日有效时间设置  -->
    <div class="layui-tab-item">
    	<table class="param_table" style="border-collapse:separate; border-spacing:0px 10px; width:325px; margin-left:12px;">
	      <tr><td colspan="4" style="height:35px;" ><input type="checkbox" id="qiyong" name="qiyong" lay-skin="primary" title="启用" lay-filter="test1"  ></td></tr>
	      <tr>
	        <td style="color:#009688;width:40px;">星期一</td>
			<td style="width:80px;"><input type="time" style="height:20px;" id="starttime2" name="starttime2" value="${wk.starttime2 }" lay-verify="required"  autocomplete="off" class="layui-input"></td>
			<td style="color:#009688;width:10px;">至</td>
			<td style="width:80px;"><input type="time" style="height:20px;" id="endtime2" name="endtime2" value="${wk.endtime2}" lay-verify="required"  autocomplete="off" class="layui-input"></td>
	      </tr>
	      <tr>
	        <td style="color:#009688;">星期二</td>
			<td style="width:80px;"><input type="time" style="height:20px;" id="starttime3" name="starttime3" value="${wk.starttime3}" lay-verify="required" autocomplete="off" class="layui-input"></td>
			<td style="color:#009688;">至</td>
			<td style="width:80px;"><input type="time" style="height:20px;" id="endtime3"  name="endtime3" value="${wk.endtime3}" lay-verify="required" autocomplete="off" class="layui-input"></td>
	      </tr>
	      <tr>
	        <td style="color:#009688;">星期三</td>
			<td style="width:80px;"><input type="time" style="height:20px;" id="starttime4" name="starttime4" value="${wk.starttime4}" lay-verify="required" autocomplete="off" class="layui-input"></td>
			<td style="color:#009688;">至</td>
			<td style="width:80px;"><input type="time" style="height:20px;" id="endtime4" name="endtime4" value="${wk.endtime4}" lay-verify="required" autocomplete="off" class="layui-input"></td>
	      </tr>
	      <tr>
	        <td style="color:#009688;">星期四</td>
			<td style="width:80px;"><input type="time" style="height:20px;" id="starttime5" name="starttime5" value="${wk.starttime5}" lay-verify="required" autocomplete="off" class="layui-input"></td>
			<td style="color:#009688;">至</td>
			<td style="width:80px;"><input type="time" style="height:20px;" id="endtime5" name="endtime5" value="${wk.endtime5}" lay-verify="required" autocomplete="off" class="layui-input"></td>
	      </tr>
	      <tr>
	        <td style="color:#009688;">星期五</td>
			<td style="width:80px;"><input type="time" style="height:20px;" id="starttime6" name="starttime6" value="${wk.starttime6}" lay-verify="required" autocomplete="off" class="layui-input"></td>
			<td style="color:#009688;">至</td>
			<td style="width:80px;"><input type="time" style="height:20px;" id="endtime6" name="endtime6" value="${wk.endtime6}" lay-verify="required" autocomplete="off" class="layui-input"></td>
	      </tr>
	      <tr>
	        <td style="color:#009688;">星期六</td>
			<td style="width:80px;"><input type="time" style="height:20px;" id="starttime7" name="starttime7" value="${wk.starttime7}" lay-verify="required" autocomplete="off" class="layui-input"></td>
			<td style="color:#009688;">至</td>
			<td style="width:80px;"><input type="time" style="height:20px;" id="endtime7" name="endtime7" value="${wk.endtime7}" lay-verify="required" autocomplete="off" class="layui-input"></td>
	      </tr>
	      <tr>
	        <td style="color:#009688;">星期日</td>
			<td style="width:80px;"><input type="time" style="height:20px;" id="starttime1"  name="starttime1" value="${wk.starttime1}" lay-verify="required" autocomplete="off" class="layui-input" <c:if test="${kongzhi.sensorEnable1==1 }">checked="checked"</c:if>></td>
			<td style="color:#009688;">至</td>
			<td style="width:80px;"><input type="time" style="height:20px;" id="endtime1" name="endtime1" value="${wk.endtime1}" lay-verify="required" autocomplete="off" class="layui-input" ></td>
	      </tr>
      </table>
    </div> 
    		<br />
          	
    </div>
</div>
</form>

<input type="button" value="使用此配置" onclick="search()" class="layui-btn layui-btn-sm"  style="margin-left:130px;"/>
<input type="button" value="查看" onclick="cha()" class="layui-btn layui-btn-sm"  style="margin-left:240px; margin-top: -50px;"/>

</body>
</html>